#ifndef _MAP_H
#define _MAP_H

//includes
#include <string.h>
#include <stdio.h>
#include <allegro.h>
#include "alleg.h"

//defines
#define LEFT                0
#define RIGHT               1
#define UP                  2
#define DOWN                3
#define TILE_NO_COLL        0
#define TILE_COLL           1
#define TILE_DAMAGE         2
#define TILE_DESTROY        3
#define TILE_NO_MOVE        0
#define TILE_UP             1
#define TILE_DOWN           2
#define TILE_RIGHT          3
#define TILE_LEFT           4
#define MAP_H                 25
#define MAP_W                 40
#define TILE_SIZE             16
#define SCREEN_SIZE_W         640
#define SCREEN_SIZE_H         480
#define ALT_SCREEN_SIZE_W     1024
#define ALT_SCREEN_SIZE_H     768
#define EDIT_MAP_SIZE_W       640
#define EDIT_MENU_SIZE_W      640
#define EDIT_MAP_SIZE_H       400
#define EDIT_MENU_SIZE_H      80
#define ALT_EDIT_MAP_SIZE_W   1024
#define ALT_EDIT_MENU_SIZE_W  1024
#define ALT_EDIT_MAP_SIZE_H   544
#define ALT_EDIT_MENU_SIZE_H  224

//Globals 

struct TILE{
    int      bmp;                                //bitmap index of tile
    float      x1;                                 //X coordinate location
    float      y1;                                 //Y coordinate location
    float      x2;                                 //X coordinate offset
    float      y2;                                 //Y coordinate offset
    int      att;                               //Current Attribute of Tile
    int      mov;                               //Direction if moveable
    int      energy;                            //Resistence before it can be destroyed
}tiles[MAP_H][MAP_W];

BITMAP   *tile[46];                                 //Holds bitmap for each tile
DATAFILE *maptiles;                             //Data file for map tiles
BITMAP   *buffer;                               // Create buffer for double buffering
BITMAP   *menu_buffer;                     // Create secondary buffer for stretching bitmaps if GFX mode is changed higher

        
//function declarations
void init_tiles(void);                                       //Initialize the tiles
void draw_map();                                           //Draw editor map
void destroy_tiles(void);                                  //Destroys the tileset
int open_doors(void);                                     //Opens all the door looking tiles
int close_doors(void);                                    //Closes doors having exit labeled on them
int save_map(void);                                       //Save map data
int load_map(char map_name[24]);                                       //Load map data
char *get_map_number(int num);
int load_test_map(BITMAP *back);

int map[MAP_H][MAP_W];

#endif
